/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package submarines;

/**
 *
 * @author sshiran
 */
public class Square {

    private char sign;
    private boolean taken;
    private transient Square leftSquare ;
    private transient Square rightSquare;
    private transient Square upSquare;
    private transient Square downSquare ;
    private transient Submarines shipType;
            
  
    public Square()
    {
        this.sign = Config.EMPTY_SQUARE_SIGN;
        this.taken = false;
        this.leftSquare = null;
        this.rightSquare = null;
        this.upSquare = null;
        this.downSquare = null;
    }

    public Square(char sign)
    {
        this.sign = sign;
        this.taken = isSquareTaken() ;
        this.leftSquare = null;
        this.rightSquare = null;
        this.upSquare = null;
        this.downSquare = null;
    }
    
    public char getSign()
    {
        return sign;
    }

    public void setSign(char sign)
    {
        this.sign = sign;
        this.taken = this.isSquareTaken();
    }
    
    public void setShip(Submarines sub) {
        shipType = sub;
    }
    
    public Submarines getWhatShip()
    {
        return shipType;
    }
    
    public final boolean isSquareTaken()
    {
        if ( this.sign != Config.EMPTY_SQUARE_SIGN)
        {
            return true;
        }
        return false;
    }
    
    public boolean isSquereHit()
    {
        if(this.sign == Config.SUB_SQUARE_SIGN)
            return true;
        else
            return false;
    }
        public Square getDownSquare() {
        return downSquare;
    }

    public void setDownSquare(Square DownSquare) {
        this.downSquare = DownSquare;
    }

    public Square getLeftSquare() {
        return leftSquare;
    }

    public void setLeftSquare(Square LeftSquare) {
        this.leftSquare = LeftSquare;
    }

    public Square getRightSquare() {
        return rightSquare;
    }

    public void setRightSquare(Square RightSquare) {
        this.rightSquare = RightSquare;
    }

    public Square getUpSquare() {
        return upSquare;
    }

    public void setUpSquare(Square UpSquare) {
        this.upSquare = UpSquare;
    }


}
